﻿using System.IO;
using System.Text;

namespace Bee.Infrastructure
{
    /// <summary>
    /// IO类
    /// </summary>
    public class IoHelper
    {
        /// <summary>
        /// 字符串转流
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static Stream StringToStream(string str)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(str);
            MemoryStream stream = new MemoryStream(bytes);
            return stream;
        }

        /// <summary>
        /// 流转字符串
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static string StreamToString(Stream stream)
        {
            byte[] bytes = new byte[stream.Length];
            return Encoding.UTF8.GetString(bytes);
        }

    }
}
